const { User} = require('../../model/user')

module.exports =  async (req,res)=>{

const id= req.query.id

if(id){
    let result = await User.findOne({_id: id})
    // console.log(result)
    res.render('admin/user-edit',{
        username:req.session.username,
        userID:id,
        user:result,
        url:'/admin/user-edit?id='+id
    })

}else{
    res.render('admin/user-edit',{
        username:req.session.username,
        url:'/admin/user-add'
    })
}

    
}